<!--弹框组件-->
<template>
    <transition name="fade" mode="out-in">
        <div
            v-if="showPop"
            class="PopconfirmFlex"
            :style="{ 'z-index': zIndex, position: isChildren ? 'static' : 'fixed' }"
        >
            <div class="PopconfirmLayout" :style="{ width: w }">
                <div class="Popconfirm_header">
                    <span></span>
                    <span>{{ title }}</span>
                    <img src="@img/close.png" alt="" @click="close" />
                </div>
                <slot />
            </div>
        </div>
    </transition>
</template>
<script lang="ts" setup>
// 在同一文件中的接口或类型字面量的引用
interface Props {
    /** 弹框宽度，尽量用响应式单位 */
    w?: string;
    /* 标题 */
    title?: string;
    /* 显示层级 */
    zIndex?: number;
    /** 显示弹框 */
    showPop: boolean;
    /** 嵌套弹框 */
    isChildren?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
    w: '46%',
    title: '',
    zIndex: 1,
    showPop: false,
    isChildren: false
});
const emit = defineEmits<{
    (e: 'update:showPop', data: boolean): void;
}>();

const close = () => {
    emit('update:showPop', false);
};
</script>
<style lang="scss" scoped>
.PopconfirmFlex {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 187px;
    width: 100vw;
    height: auto;
}
.PopconfirmLayout {
    width: 46%;
    background: rgba(3, 33, 58, 0.9);
    position: relative;
    z-index: 4;
}

.Popconfirm_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: url('@img/PopconfirmHeader.png') no-repeat;
    background-size: 100% 100%;
    height: 50px;
    line-height: 50px;
    font-weight: 550;
    font-size: 18px;
    letter-spacing: 2px;
    img {
        width: 18px;
        height: auto;
        margin-right: 16px;
        cursor: pointer;
    }
    span {
        &:last-of-type {
            @include fontCustomStyle(#0e96ff, 18px);
            margin-left: 65px;
        }
    }
}
</style>
